package com.bachongLightNovel.works.feign;

import com.bachongLightNovel.model.dto.audit.AuditNovelDto;
import com.bachongLightNovel.model.vo.audit.AuditNovelVo;
import com.bachongLightNovel.works.mapper.WorksNovelMapper;
import com.bachongLightNovel.works.service.WorksNovelService;
import com.bachongLightNovel.works.IWorksNovelClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author vermouth
 */
@RestController
@Slf4j
public class WorksNovelClient implements IWorksNovelClient {


    @Autowired
    private WorksNovelService worksNovelService;

    /**
     * 获取所有待审核状态的小说列表(status==1)
     * @return List<AuditNovelVo>
     */
    @GetMapping("api/works/novel/feign/get-audits")
    public List<AuditNovelVo> getAuditList() {
        log.info("feign:获取所有待审核状态的小说列表");
        return worksNovelService.getAudits();
    }

    /**
     * 设置审核状态
     * @param dto
     * @return
     */
    @PutMapping("api/works/novel/feign/set-status")
    public boolean setAuditStatus(AuditNovelDto dto) {
        log.info("feign:设置审核状态：{}",dto);
        return worksNovelService.setAuditStatus(dto);
    }

    /**
     * 根据小说名获取小说id
     * @param novelName :
     * @return Long
     */
    @Override
    @GetMapping("api/works/novel/feign/get-novelId")
    public List<Long> getNovelIdByNovelName(@RequestParam String novelName) {
        log.info("feign:根据小说名获取小说id：{}",novelName);
        return worksNovelService.getNovelIdByNovelName(novelName);
    }

    /**
     * 根据小说id获取小说名
     * @param novelId :
     * @return String
     */
    @Override
    @GetMapping("api/works/novel/feign/get-novelName")
    public String getNovelNameById(@RequestParam Long novelId) {
        log.info("feign:根据小说id获取小说名");
        return  worksNovelService.getNovelNameById(novelId);
    }
}
